package com.xcity.pomelo.push.msg;

import com.xcity.db.entity.Mail;
import com.xcity.pomelo.PomeloRoute;
import com.xcity.pomelo.push.AbstractMessagePush;
import com.xcity.pomelo.response.MailListResponse.MailAttach;

import naga.x.net.impl.pomelo.PomeloMessage;
import naga.x.net.impl.pomelo.protocol.Message;

@PomeloMessage(type = Message.Type.PUSH, route = PomeloRoute.PUSH_MESSAGE)
public class NewMailPush extends AbstractMessagePush {

	protected long roleId; // dest player id
	protected int id; // mail id
	protected String title;
	protected String content;
	protected long createTime;
	protected byte checked;
	protected byte received;
	protected Object extra;
	
	public NewMailPush(Mail ref) {
		super(MSG_NEW_MAIL);
		this.roleId = ref.getDestId();
		this.id = ref.getId();
		this.title = ref.getTitle();
		this.content = ref.getContent();
		this.createTime = ref.getPostTime().getTime();
		this.checked = (byte) (com.xcity.db.entity.Mail.STATE_UNREAD == ref.getState() ? 0 : 1);
		this.received = (byte) (com.xcity.db.entity.Mail.STATE_RECEIVED == ref.getState() ? 1 : 0);
		com.xcity.game.mail.MailAttach attach = ref.getAttachment();
		this.extra = attach != null && !attach.isEmpty() ? new MailAttach(attach) : "";
	}

	public long getRoleId() {
		return roleId;
	}

	public void setRoleId(long roleId) {
		this.roleId = roleId;
	}

	public int getId() {
		return id;
	}

	public void setId(int id) {
		this.id = id;
	}

	public String getTitle() {
		return title;
	}

	public void setTitle(String title) {
		this.title = title;
	}

	public String getContent() {
		return content;
	}

	public void setContent(String content) {
		this.content = content;
	}

	public long getCreateTime() {
		return createTime;
	}

	public void setCreateTime(long createTime) {
		this.createTime = createTime;
	}

	public byte getChecked() {
		return checked;
	}

	public void setChecked(byte checked) {
		this.checked = checked;
	}

	public byte getReceived() {
		return received;
	}

	public void setReceived(byte received) {
		this.received = received;
	}

	public Object getExtra() {
		return extra;
	}

	public void setExtra(Object extra) {
		this.extra = extra;
	}

}
